package qj.concurrent;

import qj.pooling.PoolManagable;
import qj.pooling.SimpleObjectPool;

/**
 *
 */
class ServantThreadPool extends SimpleObjectPool implements PoolManagable {
    private ServantManager manager;

    /**
     * @param manager
     */
    public ServantThreadPool(ServantManager manager) {
        super(LazyWorker.getInstance());
        this.manager = manager;
        this.setPoolManager(this);
    }

    public Object createNew() {
        ServantThread servantThread = new ServantThread(manager);
        servantThread.start();
        return servantThread;
    }

    public boolean bath(Object obj) {
        return true;
    }

    public boolean prepare(Object obj) {
        return true;
    }

    public void destroy(Object obj) {
        ((ServantThread)obj).kill();
    }
}
